<?php
    include '../../JHeader.php';
    require_once '../../Database/Database.php';

    if(isset($_GET['id']))
    {
        $id = $_GET['id'];
        $db = new Database();
        $db->Connect();
        $series = $db->Select('Series', 'ID_Series = ' . $id);
        $db->Disconnect();

        if($series)
        {
            $page = 'races';
            if(isset($_GET['page']))
            {
                $page = strtolower($_GET['page']);
            }

            /**
            * Funktion, um das Admin-Menü anzuzeigen.
            *
            * @author Timo
            */
            function ShowSeriesMenu($page, $series_id)
            {
                echo '<table>';
                echo '<tr id="row_one">';
                if($page == 'races')
                {
                    echo '<td class="menu_active">';
                }
                else
                {
                    echo '<td class="menu">';
                }
                echo '<a href="index.php?id=' . $series_id . '&page=races">Rennen</a></td>';

                echo '</tr>';
                //--------------------------------------------------------------------------------------------------
                echo '<tr id="row_two">';
                if($page == 'tracks')
                {
                    echo '<td class="menu_active">';
                }
                else
                {
                    echo '<td class="menu">';
                }
                echo '<a href="index.php?id=' . $series_id . '&page=tracks">Strecken</a></td>';

                echo '</tr>';
                echo '</table>';
            }

            function ShowTitel($page)
            {
                switch($page)
                {
                    case 'races': echo 'Rennen';
                                        break;

                    case 'tracks': echo 'Strecken';
                                        break;

                    default: echo 'Unknown Page';
                                break;
                }
            }

            function ShowSeriesContent($page)
            {
                switch($page)
                {
                    case 'races': include 'races.php';
                                        break;

                    case 'tracks': include 'tracks.php';
                                        break;

                    default: echo 'Unknown Page';
                                break;
                }
            }
?>
<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="../css/default.css" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>
            <?php
                ShowTitel($page);
                echo ' | ' . $series[0]->Name;
            ?>
        </title>
    </head>
    <body>
        <?php
            ShowSeriesMenu($page, $id);
            ShowSeriesContent($page);
        ?>
    </body>
</html>
<?php
        }
        else
        {
            echo 'Ung&uuml;ltige Serien ID.';
        }
    }
    else
    {
        echo 'Keine Serien ID.';
    }
?>